package com.miku.mikuapiclientsdk.config;

import com.miku.mikuapiclientsdk.client.MikuApiClient;
import com.miku.mikuapiclientsdk.service.ApiService;
import com.miku.mikuapiclientsdk.service.impi.ApiServiceImpl;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties("miku.qpi.client")
@ComponentScan
public class MikuClientConfig {

    /**
     * 访问密钥
     */
    private String accessKey;


    /**
     * 秘密密钥
     */
    private String secretKey;

    /**
     * 网关
     */
    private String host;

    @Bean
    public MikuApiClient mikuApiClient(){
        return new MikuApiClient(accessKey,secretKey);
    }

    @Bean
    public ApiService apiService(){
        ApiServiceImpl apiService=new ApiServiceImpl();
        apiService.setMikuApiClient(new MikuApiClient(accessKey,secretKey));
        if (StringUtils.isNotBlank(host)){
            apiService.setGatewayHost(host);
        }

        return apiService;
    }

}
